package com.sc.VenusQueryBeta.ui.fragments.home;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import com.hengjun.kingstar.sdk.base.fragment.BaseCompatFragment;
import com.sc.VenusQueryBeta.R;
import com.sc.VenusQueryBeta.ui.fragments.home.child.HomeFragment;


/**
 * Created by SC-02 on 2018/9/19.
 * 这个是每个fragment中的根fragment 要继承BaseCompatFragment  即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment
 * 在根fragment里面可以加载子fragment
 * 主页根fragment
 */

public class HomeRootFragment extends BaseCompatFragment {

    /**
     * 实例化
     *
     * @return
     */
    public static HomeRootFragment newInstance() {
        Bundle bundle = new Bundle();
        HomeRootFragment homeRootFragment = new HomeRootFragment();
        homeRootFragment.setArguments(bundle);
        return homeRootFragment;
    }

    /**
     * 写布局
     *
     * @return 布局
     */
    @Override
    public int getLayoutId() {
        return R.layout.fragment_home;
    }

    /**
     * 初始化这个布局的UI
     *
     * @param view               view
     * @param savedInstanceState savedInstanceState
     */
    @Override
    public void initUI(View view, @Nullable Bundle savedInstanceState) {
        if (findChildFragment(HomeFragment.class)==null) {
            loadRootFragment(R.id.fl_container, HomeFragment.newInstance());
        }
    }

}
